home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 4,401 to 4,500 / aol-file-protocol-4400-4401-to-4500.zip / AOLDLs / PDA-Newton Development / Newt 3.4 (develop apps,pkgs).sit / newt-devenv-34.sit / applic0.nwt next >
Text File  |  1998-01-25  |  5KB  |  185 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. applic0.nwt -- Sloup format
  6. 25 Jan 1998
  7. Copyright 1994-98 S. Weyer.  All Rights Reserved Worldwide.
  8.  
  9. A simple introduction to creating applications with Newt. This is a variation
  10. on a version described in article "Building Native Newton Applications with
  11. Newt" in PIE Developers, July 1994.
  12.  
  13. corresponds to code in NewtATut 1.5 tutorial
  14.  
  15. To minimize text entry, use the Sloup utility and a terminal emulator to
  16. transfer this text file as paragraphs in the Notepad.  The folder in 2nd line
  17. is currently set on nil (Unfiled); select same folder in Newt to load.
  18.  
  19. Tap Expr button, select expression :doObj('add, 'MyApp).
  20. Tap Eval, select MyApp, then select each subsequent object in list
  21. to create application incrementally.  Or, select :doObj('buildCO, 'MyApp)
  22. to build entire application in one command.
  23.  
  24. This version of app supports Rotate on NOS 2.x, so you can build application
  25. in Landscape orientation, or Rotate after application has been created/saved.
  26. ----------
  27. MyApp
  28. //:doObj('buildCO,'MyApp)
  29. //:doObj('add,'MyApp)
  30. {_proto: protoApp,
  31. viewBounds: nil, // compute in viewSetupFormScript
  32. title: "Hello World",
  33. viewSetupFormScript: func()
  34. begin
  35.     local ap := GetAppParams(); // use full (current) screen
  36.     self.viewBounds := RelBounds(
  37.         ap.AppAreaLeft, ap.AppAreaTop,
  38.         ap.AppAreaWidth, ap.AppAreaHeight);
  39.     inherited:?viewSetupFormScript();
  40. end,
  41. ReorientToScreen: func() // support Rotate for NOS 2.x
  42.     begin
  43.         :SyncView();
  44.         :RedoChildren();
  45.     end,
  46. helpBook: :helpBookTemplate(),
  47. helpView: NIL,
  48. viewQuitScript: func()
  49. begin
  50.     if helpView then helpView:close();
  51.     helpView := NIL;
  52.     inherited:?viewQuitscript();
  53. end,
  54. _package: {
  55.     shortTitle: "Hello", // a shorter title for Extras if you install
  56.     },
  57. }
  58. ----------
  59. MyApp+button
  60. {_proto: protoTextButton,
  61. viewBounds: RelBounds(100,100,40,16),
  62. text: "About",
  63. buttonClickScript: func()
  64.     if float exists
  65.     then float:open()
  66.     else PlaySound(@102), // ROM_funbeep
  67. }
  68. ----------
  69. MyApp+float
  70. {_proto: protoFloatNGo, // an empty floating view to contain about text
  71. viewBounds: RelBounds(20,120,150,100),
  72. }
  73. ----------
  74. MyApp.float+aboutText
  75. {_proto: protoAboutText,
  76. text:
  77. "This demo created by
  78. <A HREF=\"mailto:" &
  79.     :GetUserConfig('mailAccount) & "\">" &
  80.     :GetUserConfig('name) & "</A>
  81. with the help of Newt,
  82. the lizard wizard.
  83.  
  84. <A HREF=\"http://members.bellatlantic.net/~sweyer/newton/index.htm\">Steve's releases page</A>",
  85. }
  86. ----------
  87. MyApp.myInputProto
  88. {_proto: protoInputLine,
  89. text: "",
  90. value: 0,
  91. viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed,
  92. getTextValue: func() // from text, set number value (used by total)
  93.     begin
  94.     self.value := StringToNumber(text);
  95.     if not value then value := 0;
  96.     end,
  97. viewChangedScript: func(slot,view)
  98.     if slot='text
  99.     then begin
  100.         :getTextValue();
  101.         if total exists then total:update();
  102.         end,
  103. viewSetupFormScript: func()
  104.     begin
  105.     self.text := Clone(text);
  106.     :getTextValue();
  107.     inherited:?viewSetupFormScript();
  108.     end,
  109. }
  110. ----------
  111. MyApp+num1
  112. {_proto: myInputProto,
  113. viewBounds: RelBounds(130,20,100,20),
  114. }
  115. ----------
  116. MyApp+num2
  117. {_proto: myInputProto,
  118. viewBounds: RelBounds(130,45,100,20),
  119. }
  120. ----------
  121. MyApp+total
  122. {_proto: protoStaticText,
  123. viewBounds: RelBounds(130,80,100,16),
  124. text: "Total", // initial text
  125. numVars: ['num1, 'num2],
  126. getValueText: func() // return text from summing field values
  127.     begin
  128.     local tot := 0, field;
  129.     foreach field in numVars // add up num1.value + num2.value etc.
  130.     do tot := tot + GetVariable(self,field).value;
  131.     if round exists and round.viewValue
  132.     then tot := RIntToL(tot);
  133.     NumberStr(tot); // return string
  134.     end,
  135. update: func()
  136.     SetValue(self,'text,:getValueText()),
  137. viewSetupFormScript: func()
  138.     begin
  139.     self.text := :getValueText();
  140.     inherited:?viewSeutpFormScript();
  141.     end,
  142. }
  143. ----------
  144. MyApp+round
  145. {_proto: protoCheckbox,
  146. viewBounds: RelBounds(20,78,50,16),
  147. text: "Round?",
  148. valueChanged: func()
  149.     if total exists then total:update(),
  150. }
  151. ---------
  152. MyApp+info
  153. {_proto: protoInfoButton,
  154. viewJustify: 134, /* vjCenterH + vjCenterV + vjParentBottomV */
  155. viewBounds: RelBounds(25,-18,13,13),
  156. DoInfoAbout: func()
  157.     if float exists
  158.     then float:open()
  159.     else PlaySound(@102), /* ROM_funbeep */
  160. DoInfoHelp: func()
  161. begin
  162.     local ttim := GetRoot().tinyTim;
  163.     if not helpView
  164.     then helpView := BuildContext({
  165.         _proto: ttim._proto,
  166.         bookRef: helpBook});
  167.     ttim:close();
  168.     helpView:openManual(helpBook);
  169. end,
  170. }
  171. ----------
  172. MyApp.helpBook+page1
  173. .subject 1
  174. Describe Hello World
  175. .story
  176. Read the NewtATut tutorial.
  177. ----------
  178. MyApp.helpBook+page2
  179. .subject 1
  180. Use Hello World
  181. .story
  182. Very simple -- just write in some numbers.
  183. ----------
  184. BYE!
  185.